<?php

use App\Http\Controllers\College\Merchant\OnlineCourseController;
use App\Http\Controllers\College\Merchant\TrainOrderController;
use App\Http\Controllers\College\Web\CategoryController;
use App\Http\Controllers\College\Web\TrainingOrderController;
use App\Http\Controllers\College\Web\CoursesController;
use App\Http\Controllers\College\Web\TrainingPlansController;
use Illuminate\Support\Facades\Route;
use App\Http\Middleware\OpenShop\MerchantAppAuth;
use App\Http\Middleware\OpenShop\FeishuWebAuth;
use App\Http\Controllers\College\Merchant\CollegeInputController;

/**
 * 商家APP-商家在线学习
 */

Route::get('test', function () {
    return '商家APP-商家在线学习';
});


/**
 * 商家端
 * merchant
 */
Route::prefix('merchant')->middleware(MerchantAppAuth::class)->group(function () {

    //我要学习
    Route::prefix('course')->group(function () {
        //在线课堂列表
        Route::get('list', [OnlineCourseController::class, 'list']);
        //在线课堂详情
        Route::get('detail/{id}', [OnlineCourseController::class, 'detail'])->where('id', '[0-9]+');

        //学习进度更新
        Route::post('updateProgress/{id}', [TrainOrderController::class, 'updateProgress'])->where('id', '[0-9]+');
    });

    //我的培训
    Route::prefix('train')->group(function () {
        //培训订单列表
        Route::get('list', [TrainOrderController::class, 'list']);
        //培训订单详情
        Route::get('detail/{id}', [TrainOrderController::class, 'detail'])->where('id', '[0-9]+');

        //商家确认培训计划 ⬇️
        Route::get('getCampusAndStaff/{id}', [TrainOrderController::class, 'getCampusAndStaff'])->where('id', '[0-9]+'); //选择校区-员工
        Route::get('getPlanByCampus/{id}', [TrainOrderController::class, 'getPlanByCampus'])->where('id', '[0-9]+'); //通过校区获得对应计划
        Route::post('confirmTrainInfo/{id}', [TrainOrderController::class, 'confirmTrainInfo'])->where('id', '[0-9]+'); //商家确认培训信息
    });


    // 考试
    Route::prefix('exam')->group(function () {

        // 我的测评列表
        Route::get('lists', [CollegeInputController::class, 'lists']);

        // 试卷配置信息
        Route::get('detail/{id}', [CollegeInputController::class, 'detail']);

        // 开始考试
        Route::post('start/{id}', [CollegeInputController::class, 'start']);

        // 表单
        Route::prefix('inputs')->group(function () {
            Route::get('info/{id}', [CollegeInputController::class, 'info']);
            Route::post('update/{id}', [CollegeInputController::class, 'update']);
            Route::post('submit/{id}', [CollegeInputController::class, 'submit']);
        });
    });
});

/**
 * web
 */
Route::prefix('web')->middleware([FeishuWebAuth::class])->group(function () {
    /**
     * 课程分类
     */
    Route::prefix('category')->group(function () {
        Route::get('', [CategoryController::class, 'list']);
        Route::get('{id}', [CategoryController::class, 'info']);
        Route::post('', [CategoryController::class, 'add']);
        Route::put('{id}', [CategoryController::class, 'update']);
        Route::delete('{id}', [CategoryController::class, 'delete']);
    });

    //培训订单 ⬇️
    Route::prefix('trainOrder')->group(function () {
        Route::get('list', [TrainingOrderController::class, 'list']);  // 培训订单列表
        Route::get('detail/{id}', [TrainingOrderController::class, 'detail'])->where('id', '[0-9]+');  // 培训订单详情
        Route::get('getShopStaff/{shopId}', [TrainingOrderController::class, 'getShopStaff'])->where('shopId', '[0-9]+'); //获得门店的员工列表
        Route::get('getPlanByCampus/{id}', [TrainOrderController::class, 'getPlanByCampus'])->where('id', '[0-9]+'); //通过校区获得对应计划

        Route::post('user/add/{id}', [TrainingOrderController::class, 'userAdd'])->where('id', '[0-9]+');  // 新增参训人员
        Route::post('user/remove/{id}', [TrainingOrderController::class, 'userRemove'])->where('id', '[0-9]+');  // 移除参训人员
        Route::post('close/{id}', [TrainingOrderController::class, 'close'])->where('id', '[0-9]+');  // 关闭培训订单
        Route::post('confirm/{id}', [TrainingOrderController::class, 'confirm'])->where('id', '[0-9]+');  // 商学院确认
        Route::post('upload/{id}', [TrainingOrderController::class, 'upload'])->where('id', '[0-9]+');  // 实操上传
        Route::post('add',  [TrainingOrderController::class, 'orderAdd']);  // 手动创建培训单
        Route::post('repair',  [TrainingOrderController::class, 'orderRepair']);  // 补考
        Route::post('editTeacherShop/{id}', [TrainingOrderController::class, 'editTeacherShop']); // 修改带训门店
    });

    /**
     * 课程
     */
    Route::prefix('courses')->group(function () {
        Route::get('', [CoursesController::class, 'list']);
        Route::get('{id}', [CoursesController::class, 'info']);
        Route::post('', [CoursesController::class, 'add']);
        Route::put('{id}', [CoursesController::class, 'update']);
        Route::delete('{id}', [CoursesController::class, 'delete']);
    });

    /**
     * 培训计划
     */
    Route::prefix('trainingPlans')->group(function () {
        Route::get('', [TrainingPlansController::class, 'list']);
        Route::get('{id}', [TrainingPlansController::class, 'info']);
        Route::post('', [TrainingPlansController::class, 'add']);
        Route::put('{id}', [TrainingPlansController::class, 'update']);
        Route::delete('{id}', [TrainingPlansController::class, 'delete']);
        Route::post('addBatch', [TrainingPlansController::class, 'addBatch']);
    });

});
